package msa.ch03.data;

import javax.wireless.messaging.MultipartMessage;

public class StoredMessage {

	private final String subject;
	
	private final String[] adressesTo;
	private final String[] adressesCc;
	private final String[] adressesBcc;
	private final String[] adressesFrom;
	
	public StoredMessage(MultipartMessage message) {
		subject = message.getSubject();
		
		if (message.getAddresses("to") != null) {
			adressesTo = message.getAddresses("to");
		} else {
			adressesTo = new String[0];
		}
		if (message.getAddresses("cc") != null) {
			adressesCc = message.getAddresses("cc");
		} else {
			adressesCc = new String[0];
		}
		if (message.getAddresses("bcc") != null) {
			adressesBcc = message.getAddresses("bcc");
		} else {
			adressesBcc = new String[0];
		}
		if (message.getAddresses("from") != null) {
			adressesFrom = message.getAddresses("from");
		} else {
			adressesFrom = new String[0];
		}
		
		// TODO message.getHeader()
		
		// TODO finish
	}

	public String getSubject() {
		return subject;
	}

	public String toString() {
		return "" + subject;
	}

	public String[] getAdressesTo() {
		return adressesTo;
	}

	public String[] getAdressesCc() {
		return adressesCc;
	}

	public String[] getAdressesBcc() {
		return adressesBcc;
	}

	public String[] getAdressesFrom() {
		return adressesFrom;
	}
	
}
